-
Notifications
You must be signed in to change notification settings - Fork 454
[vpp] Enable copy pass thru for VAAPI #1268
[vpp] Enable copy pass thru for VAAPI #1268
Conversation
@@ -908,6 +908,8 @@ namespace MfxHwVideoProcessing | |||
mfxFrameSurface1 *pInputSurface, | |||
mfxFrameSurface1 *pOutputSurface); | |||
|
|||
mfxStatus IsCopyPassThroughPreferred(bool &preferred) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This design looks ugly, this function should simply return bool
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this function:). Both prototype (+1 to @mgonchar) and how it named/what it does. It returns not deterministic result: "I check copy pass thru, maybe I like it maybe not - decide later". I would like to see function named useSOMETHING() with the obvious inclination.
To be honest, I got lost in CopyPassThrough name. What it actually mean? Copy with memcpy or CM?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to say something like "performance of CopyPassThrough is good, you want to use it" vs "it's better to omit CopyPassThrough" and to hide low-level details what is used inside and what is faster.
@@ -3115,9 +3134,16 @@ mfxStatus VideoVPPHW::VppFrameCheck( | |||
#endif | |||
MFX_CHECK_STS(sts); | |||
|
|||
bool useCopyPassThrough = false; | |||
if (true == m_config.m_bCopyPassThroughEnable && false == IsRoiDifferent(pTask->input.pSurf, pTask->output.pSurf)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like bool
to bool
conversions.
As for me
if (m_config.m_bCopyPassThroughEnable && !IsRoiDifferent(pTask->input.pSurf, pTask->output.pSurf))
is much better.
But I won't insist of changing this if you like your approach
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is legacy. But I'm for the change, sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -2962,6 +2962,25 @@ mfxStatus VideoVPPHW::Close() | |||
} // mfxStatus VideoVPPHW::Close() | |||
|
|||
|
|||
mfxStatus VideoVPPHW::IsCopyPassThroughPreferred(bool &preferred) const | |||
{ | |||
if (m_pCore->GetVAType() != MFX_HW_VAAPI || m_ioMode != D3D_TO_D3D) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't this check mean that vaapi core is used?
I.e. cast on line 2979 wouldn't fail?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgonchar Yes, the cast must not fail. I don't like dropping the check, however. What can I do here, as there is no asserts in release and you think returning mfxStatus is ugly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well, currently I see two different ways:
- Leave the current code, but return false instead of error if cast fails (which is supposed to be almost impossible situation). So we just silently hide the error (not actually so, because we can use trace macro to at least signal to stdout if traces are on)
- Move to references casting, then some upper layers should deal with possible exception (which is supposed to be almost impossible situation). So we loose information about place of error occurrence.
So both of these ways are definitely not much better than current approach. I will try to figure out better solution...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asserts are enabled in release builds of master branch. They are switched off in builds of release branches. So, use assert if you feel it right.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I want to be protected from some fearless code refactoring. So checking on master' release is just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having virtual GetCmCopyStatus
in core is not an option to avoid this cast which is ugly on its own?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe adding new virtual functions to CommonCORE
is prohibited. That's why the cast was applied here.
@@ -908,6 +908,8 @@ namespace MfxHwVideoProcessing | |||
mfxFrameSurface1 *pInputSurface, | |||
mfxFrameSurface1 *pOutputSurface); | |||
|
|||
mfxStatus IsCopyPassThroughPreferred(bool &preferred) const; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this function:). Both prototype (+1 to @mgonchar) and how it named/what it does. It returns not deterministic result: "I check copy pass thru, maybe I like it maybe not - decide later". I would like to see function named useSOMETHING() with the obvious inclination.
To be honest, I got lost in CopyPassThrough name. What it actually mean? Copy with memcpy or CM?
@@ -2962,6 +2962,25 @@ mfxStatus VideoVPPHW::Close() | |||
} // mfxStatus VideoVPPHW::Close() | |||
|
|||
|
|||
mfxStatus VideoVPPHW::IsCopyPassThroughPreferred(bool &preferred) const | |||
{ | |||
if (m_pCore->GetVAType() != MFX_HW_VAAPI || m_ioMode != D3D_TO_D3D) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Asserts are enabled in release builds of master branch. They are switched off in builds of release branches. So, use assert if you feel it right.
@@ -177,6 +177,8 @@ class VAAPIVideoCORE : public CommonCORE | |||
// this function should not be virtual | |||
mfxStatus SetCmCopyStatus(bool enable); | |||
|
|||
bool GetCmCopyStatus() const { return m_bCmCopy; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Status in function name is misleading. Can we just have SetCmCopy(bool)
and bool CmCopy()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
3ca8c40
to
4113007
Compare
@@ -813,7 +813,7 @@ VAAPIVideoCORE::GetVAService( | |||
} // mfxStatus VAAPIVideoCORE::GetVAService(...) | |||
|
|||
mfxStatus | |||
VAAPIVideoCORE::SetCmCopyStatus(bool enable) | |||
VAAPIVideoCORE::SetCmCopy(bool enable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe no sense for this function to return status
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mgonchar Is it possible to change mfxStatus CMEnabledCoreInterface::SetCmCopy(bool enable)
to return void as well? Can it affect ABI of some plugins?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@onabiull : please, comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we wan't old plugins to remain functional, we need change interfaces by adding new ones. This would affect windows version in the first hand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@onabiull : Does this apply to VAAPIVideoCORE or VideoCORE or both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand Oleg correctly, CMEnabledCoreInterface
is part of plugin API and so change of return value's type is prohibited.
So, rename virtual mfxStatus CMEnabledCoreInterface::SetCmCopyStatus(bool enable)
to virtual mfxStatus CMEnabledCoreInterface::SetCmCopy(bool enable)
is also incorrect and must be reverted.
{ | ||
if (m_pCore->GetVAType() != MFX_HW_VAAPI || m_ioMode != D3D_TO_D3D) | ||
{ | ||
return true; // preferred unconditionally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
after function rename this comment is misleading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -3115,9 +3131,13 @@ mfxStatus VideoVPPHW::VppFrameCheck( | |||
#endif | |||
MFX_CHECK_STS(sts); | |||
|
|||
bool useCopyPassThrough = | |||
(m_config.m_bCopyPassThroughEnable && !IsRoiDifferent(pTask->input.pSurf, pTask->output.pSurf))? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why you don't want to move this condition to UseCopyPassThrough() as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -813,7 +813,7 @@ VAAPIVideoCORE::GetVAService( | |||
} // mfxStatus VAAPIVideoCORE::GetVAService(...) | |||
|
|||
mfxStatus | |||
VAAPIVideoCORE::SetCmCopyStatus(bool enable) | |||
VAAPIVideoCORE::SetCmCopy(bool enable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@onabiull : please, comment.
4113007
to
3bbf791
Compare
// This can't be done in ConfigureExecuteParams() because CmCopy status is set later. | ||
const VAAPIVideoCORE *vaapiCore = dynamic_cast<VAAPIVideoCORE*>(m_pCore); | ||
assert(vaapiCore); | ||
return vaapiCore->CmCopy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you know, I am not sure I like this code. I would probably go with just:
const VAAPIVideoCORE *vaapiCore = dynamic_cast<VAAPIVideoCORE*>(m_pCore);
return (vaapiCore)? vaapiCore->CmCopy(): false;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a huge "Can't happen!" and we are ignoring it silently, aren't we? Why not add
if(!vaapiCore) MFX_STS_TRACE();
at least?
@@ -2962,6 +2962,28 @@ mfxStatus VideoVPPHW::Close() | |||
} // mfxStatus VideoVPPHW::Close() | |||
|
|||
|
|||
bool VideoVPPHW::UseCopyPassThrough(const DdiTask *pTask) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name of the function should probably be: UseCmCopyPassThrough(), right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The plan was to hide mere presence of Cm. Why may a user of CopyPassThrought be interested in what is used inside? One just want fastest version, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because it seems that this function implies that CM is going to be used. At least that's what I think looking into last line in its code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I got it after offline discussion. Under copy pass through we understand any mem copy operation without VP algorithms. This can be map+memcpy or cmcopy. In different modes we prefer different copy type.
@@ -813,7 +813,7 @@ VAAPIVideoCORE::GetVAService( | |||
} // mfxStatus VAAPIVideoCORE::GetVAService(...) | |||
|
|||
mfxStatus | |||
VAAPIVideoCORE::SetCmCopyStatus(bool enable) | |||
VAAPIVideoCORE::SetCmCopy(bool enable) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@onabiull : Does this apply to VAAPIVideoCORE or VideoCORE or both?
@@ -2962,6 +2962,28 @@ mfxStatus VideoVPPHW::Close() | |||
} // mfxStatus VideoVPPHW::Close() | |||
|
|||
|
|||
bool VideoVPPHW::UseCopyPassThrough(const DdiTask *pTask) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I got it after offline discussion. Under copy pass through we understand any mem copy operation without VP algorithms. This can be map+memcpy or cmcopy. In different modes we prefer different copy type.
3bbf791
to
039ecba
Compare
// for CM availability to do fallback to VPP if there is no CM. | ||
// This can't be done in ConfigureExecuteParams() because CmCopy status is set later. | ||
const VAAPIVideoCORE *vaapiCore = dynamic_cast<VAAPIVideoCORE*>(m_pCore); | ||
assert(vaapiCore); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here you can use following macro to simplify code + use assert + use traces:
MFX_CHECK_WITH_ASSERT(vaapiCore, false);
return vaapiCore->CmCopy();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep.
d742fa8
to
c5495f7
Compare
Issue: MDP-53850 Fixes: Intel-Media-SDK#1027
c5495f7
to
0e11d31
Compare
Issue: MDP-53850
Fixes: #1027